/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bio.jpa.entities;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Diego
 */
@Entity
@Table(name = "file_data", catalog = "biodb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "FileData.findAll", query = "SELECT f FROM FileData f"),
    @NamedQuery(name = "FileData.findByIdfileData", query = "SELECT f FROM FileData f WHERE f.idFd = :idFd")})
public class FileData implements Serializable, Comparable<FileData> {
   

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_fd")
    private Integer idFd;
    @Basic(optional = false)
    @Lob
    @Column(name = "file_data")
    private byte[] fileData;
    @Column(name = "seq_id")
    private Integer seqId;
    @JoinColumn(name = "file_id_file", referencedColumnName = "id_file")
    @ManyToOne(optional = false)
    private File fileIdFile;

    public FileData() {
    }

    public FileData(Integer idFd) {
        this.idFd = idFd;
    }

    public FileData(Integer idFd, byte[] fileData) {
        this.idFd = idFd;
        this.fileData = fileData;
    }

    public Integer getIdFd() {
        return idFd;
    }

    public void setIdFd(Integer idFd) {
        this.idFd = idFd;
    }

    public byte[] getFileData() {
        return fileData;
    }

    public void setFileData(byte[] fileData) {
        this.fileData = fileData;
    }

    public Integer getSeqId() {
        return seqId;
    }

    public void setSeqId(Integer seqId) {
        this.seqId = seqId;
    }

    public File getFileIdFile() {
        return fileIdFile;
    }

    public void setFileIdFile(File fileIdFile) {
        this.fileIdFile = fileIdFile;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idFd != null ? idFd.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof FileData)) {
            return false;
        }
        FileData other = (FileData) object;
        if ((this.idFd == null && other.idFd != null) || (this.idFd != null && !this.idFd.equals(other.idFd))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bio.jpa.entities.FileData[ idFd=" + idFd + " ]";
    }
    @Override
    public int compareTo(FileData o) {
        return getSeqId().compareTo(o.getSeqId());
    }
    
}
